{extend name="common:base" /}
{block name="content"}
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf">
            <strong class="am-text-primary am-text-lg">栏目管理</strong> / <small>栏目编辑</small>
            &nbsp;&nbsp;<a id="btn_return" class="am-btn am-btn-default am-btn-xs"><i class="am-icon-reply"></i>&nbsp;返回</a>
        </div>
    </div>
    <hr/>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-4 am-u-md-push-8"></div>

        <div class="am-u-sm-12 am-u-md-8 am-u-md-pull-4">
            <form class="am-form am-form-horizontal">
                <div class="am-form-group">
                    <label for="name" class="am-u-sm-3 am-form-label">名称 / Name</label>
                    <div class="am-u-sm-9">
                        <input type="text" name="name" id="name" placeholder="名称 / Name" value="{$data.name}">
                        <small>输入栏目名称，并且唯一。</small>
                    </div>
                </div>

                <div class="am-form-group">
                    <label class="am-u-sm-3 am-form-label">状态 / Status</label>
                    <div class="am-u-sm-9">
                        <div class="am-btn-group" data-am-button>
                            <label class="am-btn am-btn-default am-btn-xs">
                                <input {eq name="data.status" value="显示"}checked="checked"{/eq} type="radio" name="status" value="1"> 显示
                            </label>
                            <label class="am-btn am-btn-default am-btn-xs">
                                <input {eq name="data.status" value="隐藏"}checked="checked"{/eq} type="radio" name="status" value="0"> 隐藏
                            </label>
                        </div>
                        <br/><small>设置栏目状态，这里如果设置隐藏，那么这个栏目下的所有文章都不显示。</small>
                    </div>
                </div>

                <div class="am-form-group">
                    <label for="sort" class="am-u-sm-3 am-form-label">排序 / Sort</label>
                    <div class="am-u-sm-9">
                        <input type="text" name="sort" id="sort" placeholder="排序 / Sort" value="{$data.sort}">
                        <small>设置栏目排序，数字越大排序越靠前。</small>
                    </div>
                </div>

                <div class="am-form-group">
                    <div class="am-u-sm-9 am-u-sm-push-3">
                        <button type="button" class="am-btn am-btn-primary">保存</button>
                    </div>
                </div>
                <input type="hidden" name="id" value="{$data.id|intval}">
            </form>
        </div>
    </div>
</div>
{/block}
{block name="footer"}
<script type="text/javascript">
$(function () {
    $('.am-btn-primary').on('click',function () {
        var flag = false;
        var form = $('.am-form');
        $('[placeholder]', form).each(function () {
            var sender = $(this);
            if (sender.val() == ''){
                ck_alert(sender.next().html());
                flag = true;return false;
            }
        });
        if (flag) {
            return;
        }
        if($('[name=status]:checked').size() <= 0){
            ck_alert('请设置显示状态');return;
        }
        $.ajax({
            type:'post',
            url:"{:url('doeditcate')}",
            dataType:'json',
            data:form.serialize(),
            success:ajax_success_func
        });
    });
});
</script>
{/block}